package tpase.KeyServer.VO;

import it.unisa.dia.gas.jpbc.Element;
import it.unisa.dia.gas.jpbc.Pairing;
import tpase.util.Util;

public class VerifyInfo {
    private Element w, ui, hi, ci, g, gamma;
    private Element x;
    Pairing pairing;

    public VerifyInfo(Element ui, Element hi, Element ci, Element x) {
        this.ui = ui;
        this.hi = hi;
        this.ci = ci;
        this.x = x;
    }
    public boolean verify() {
        // ui = vi - ci * si, hi = w^si
        // w^{ui} * hi^{ci}
        Element ti = w.duplicate().powZn(ui).add(hi.duplicate().powZn(ci));
        // gamma = g^{si}
        // g^{ui} * gamma^{ci}
        Element ti2 = g.duplicate().powZn(ui).add(gamma.duplicate().powZn(ci));
        String s = hi.toString() + w.toString() + gamma.toString() + g.toString() +  ti.toString() + ti2.toString();
        Element ci2 = Util.hash(pairing.getZr(), s);
        if (ci2.equals(ci)) {
            return true;
        } else {
            return false;
        }
    }

    public Element getX() {
        return x;
    }

    public void setX(Element x) {
        this.x = x;
    }

    public Element getW() {
        return w;
    }

    public void setW(Element w) {
        this.w = w;
    }

    public Element getUi() {
        return ui;
    }

    public void setUi(Element ui) {
        this.ui = ui;
    }

    public Element getHi() {
        return hi;
    }

    public void setHi(Element hi) {
        this.hi = hi;
    }

    public Element getCi() {
        return ci;
    }

    public void setCi(Element ci) {
        this.ci = ci;
    }

    public Element getG() {
        return g;
    }

    public void setG(Element g) {
        this.g = g;
    }

    public Element getGamma() {
        return gamma;
    }

    public void setGamma(Element gamma) {
        this.gamma = gamma;
    }

    public Pairing getPairing() {
        return pairing;
    }

    public void setPairing(Pairing pairing) {
        this.pairing = pairing;
    }
}
